package com.yuexun.beilunpatient.ui.main.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.config.Contracts;
import com.yuexun.beilunpatient.ui.bodyCheck.ui.Act_BodyCheck;
import com.yuexun.beilunpatient.ui.contractmanage.ui.Act_ContractManageRecord;
import com.yuexun.beilunpatient.ui.docAdvice.ui.Act_DocAdvice;
import com.yuexun.beilunpatient.ui.inspect.ui.Act_Inspect_List;
import com.yuexun.beilunpatient.ui.main.adapter.MenuAdapter;
import com.yuexun.beilunpatient.ui.main.bean.MenuItemBean;
import com.yuexun.beilunpatient.ui.personaldata.ui.Act_PersonalData;
import com.yuexun.beilunpatient.ui.test.ui.Act_Test_List;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2018/3/13 0013.
 */

public class Frag_Health extends KJFragment {
    @Bind(R.id.health_menu)
    GridView healthMenu;

    MenuAdapter menuAdapter;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        View view = inflater.inflate(R.layout.frag_health, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void initData() {
        menuAdapter = new MenuAdapter(healthMenu, Contracts.healthMenuList, R.layout.item_menu);
        healthMenu.setAdapter(menuAdapter);

        healthMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                MenuItemBean item = (MenuItemBean) parent.getItemAtPosition(position);
                Intent intent;
                switch (item.getPosition()) {
                    case 0://就诊记录
                        startActivity(new Intent(getActivity(), Act_ContractManageRecord.class));
                        break;
                    case 1://医嘱查询
                        startActivity(new Intent(getActivity(), Act_DocAdvice.class));
                        break;
                    case 2://化验报告单
                        startActivity(new Intent(getActivity(), Act_Test_List.class));
                        break;
                    case 3://检查报告单
                        startActivity(new Intent(getActivity(), Act_Inspect_List.class));
                        break;
                    case 4://体检信息
                        startActivity(new Intent(getActivity(), Act_BodyCheck.class));
                        break;
                    case 7://基本资料
                        startActivity(new Intent(getActivity(), Act_PersonalData.class));
                        break;
                }
            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
